package edu.gyc.mycloud.controller;

import edu.gyc.mycloud.model.MyResult;
import edu.gyc.mycloud.model.Payment;
import edu.gyc.mycloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Slf4j
public class PaymentController {

    @Resource
    private PaymentService paymentService;

    @PostMapping("/payment/create")
    public MyResult create(@RequestBody Payment payment) {
        log.info("******input payment:"+payment);
        int r = paymentService.create(payment);
        log.info("******插入结果："+r);
        if(r>0){
            return new MyResult(200,"插入数据成功",r);

        }else {
            return new MyResult(444,"插入数据失败");
        }
    }

    @GetMapping("/payment/get/{id}")
    public MyResult<Payment> getPaymentById(@PathVariable("id") Long id) {
        Payment payment = paymentService.getPaymentById(id);
        log.info("******查询结果："+payment+"\t"+"好成功了！");
        if(payment!=null){
            return new MyResult(200,"查询成功",payment);

        }else {
            return new MyResult(444,"没有对应记录，查询id："+id);
        }
    }

    @GetMapping("/hi")
    public Object hi() {
        return new MyResult(200, "汪小敏kiss you！");
    }

    @GetMapping("/hello")
    public Object hello() {
        return new MyResult(200, "赵雨静kiss you！");
    }

    @GetMapping("/kiss")
    public Object kiss() {
        return new MyResult(200, "徐睿kiss you！");
    }

    @GetMapping("/pay")
    public Object pay() {
        return new MyResult(200, "sskiss you     ！");
    }

    @GetMapping("/aa")
    public Object paaay() {
        return new MyResult(200, "sskiss you     ！");
    }

    @GetMapping("/bb")
    public Object bb() {
        return new MyResult(200, "bb you     ！");
    }
}
